package com.ccm.demo.springbootsecurity.service;

import com.ccm.demo.springbootsecurity.dao.SysMenuMapper;
import com.ccm.demo.springbootsecurity.dao.SysRoleMapper;
import com.ccm.demo.springbootsecurity.entity.SysMenu;
import com.ccm.demo.springbootsecurity.entity.SysRole;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class MenuService {

	@Resource
	private SysMenuMapper sysMenuMapper;
	@Resource
	private SysRoleMapper sysRoleMapper;

	public List<SysMenu> getAllMenu() {
		List<SysMenu> menus=sysMenuMapper.getAllMenu();
		menus.forEach(menu -> {
			List<SysRole> roles=sysRoleMapper.selectByMenuId(menu.getMenuId());
			menu.setSysRoles(roles);
		});
		return menus;
	}
}
